package com.example.springcloudwinter.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.sql.SQLException;

@Mapper
public interface VIPMapper {
	
	@Insert("insert into vip ( userId,endDate)values(#{userId}, now()+ INTERVAL 30 DAY)")
	int openMembershipByUserId (@Param("userId") String userId) throws SQLException;
	
	@Select("select count(*) from vip where userId=#{userId} AND endDate>now()")
	int checkVIPByUserId  (@Param("userId") String userId) throws SQLException;

}
